package com.itheima.web.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.Comment;
import com.itheima.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(value = "{http://127.0.0.1:81,http://127.0.0.1:82}")
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    //查询全部
    @GetMapping("/findByPage")
    public PageInfo<Comment> findByPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "5") Integer pageSize, String keyword){
        //接受数据，调用方法
        return commentService.findByPage(pageNum,pageSize,keyword);
    }
    //删除单个
    @DeleteMapping("deleteById")
    public String deleteById(Integer id){
        //调用方法
        commentService.deleteById(id);
        return "ok";
    }
    //批量删除
    @DeleteMapping("deleteIds")
    public String deleteIds(Integer[] ids){
        //调用方法
        commentService.deleteIds(ids);
        return "ok";
    }
}
